package academic.ui.client.widgets.forms;

import ui.client.GenericContainerTag;

import academic.ui.client.jquery.JQuery;

import com.google.gwt.user.client.ui.Composite;

public class FormWidget extends Composite implements HasRules{

	protected GenericContainerTag div = new GenericContainerTag("div");
	protected GenericContainerTag errorMsgs = new GenericContainerTag("div");
	
	public FormWidget() {
		div.clear();
		div.add(errorMsgs);
		errorMsgs.setStyleName("errorMsgs");
		errorMsgs.setVisible(false);
		initWidget(div);
	}

	@Override
	public Boolean checkRules() {
		errorMsgs.setVisible(false);
		errorMsgs.clear();
		return true;
	}

	@Override
	public void removeErrors() {
		JQuery.fadeOutErrors();
	}

	@Override
	public void setError(String errorMsg) {
		errorMsgs.clear();
		errorMsgs.add(new GenericContainerTag("div",errorMsg));
		JQuery.fadeInErrors();
	}
	
}
